using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using LeisureCenter.Api;
using LeisureCenter.Forms;

namespace LeisureCenter.MenuItems
{
    public class OptionsAboutSubmenuItem : IMenuItem
    {
        AboutScreen aboutScreen;

        #region IMenuItem Membres

        public string Text
        {
            get { return @"About"; }
        }

        public string IconName
        {
            get { return "about"; }
        }

        public void Execute()
        {
            ExecuteAgain();
        }

        public void ExecuteAgain()
        {
            if (this.aboutScreen == null)
            {
                this.aboutScreen = new AboutScreen();
                this.aboutScreen.Dock = DockStyle.Fill;
            }
            Program.LeisureCenterInstance.UIManager.ShowCustomScreen(this.aboutScreen, true);
        }

        public void OptionsExecute()
        {
        }

        #endregion
    }

    public class OptionsUpdateSubmenuItem : IMenuItem
    {
        #region IMenuItem Membres

        public string Text { get { return "Update"; } }

        public string IconName { get { return "update"; } }

        public void Execute()
        {
            ExecuteAgain();
        }

        public void ExecuteAgain()
        {
            Program.LeisureCenterInstance.CommandsManager.EnqueueCommand(LeisureCenterCommand.Update);
        }

        public void OptionsExecute()
        {
        }

        #endregion
    }

    public class OptionsMainMenuItem : IMenuItem
    {
        #region IMenuItem Membres

        public string Text { get { return "Options"; } }

        public string IconName { get { return "options"; } }

        public void Execute()
        {
            ExecuteAgain();
        }

        public void ExecuteAgain()
        {
            List<IMenuItem> items = new List<IMenuItem>();
            OptionsAboutSubmenuItem about = new OptionsAboutSubmenuItem();
            items.Add(about);
            items.Add(new OptionsUpdateSubmenuItem());
            Program.LeisureCenterInstance.MenuManager.FillSubmenu(items);
            about.Execute();
        }

        public void OptionsExecute()
        {
        }

        #endregion
    }

    public class OptionsMainMenuItemsProvider : IMainMenuItemsProvider
    {
        IMenuItem[] items = new IMenuItem[] { new OptionsMainMenuItem() };

        #region IMainMenuItemsProvider Membres

        public IEnumerable<IMenuItem> Items
        {
            get { return items; }
        }

        #endregion
    }
}
